package com.credithc.customers.manager.schedule;

import com.credithc.customers.manager.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * Created with IntelliJ IDEA.
 * Company: Credithc
 *
 * @author mxw
 * @date 2019/5/6 10:29
 * description:
 */
@Slf4j
public class StatsCustomerExtendJob implements Job {

    @Autowired
    private ScheduleService scheduleService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("===========================开始统计用户各系统总数===========================");

        LocalDateTime startTime = LocalDateTime.now();
        scheduleService.statsCustomerExtend(startTime.toLocalDate());
        LocalDateTime endTime = LocalDateTime.now();

        Duration duration =Duration.between(startTime,  endTime);
        log.info("===========================结束统计用户各系统总数, 耗时:{}秒===========================", duration.getSeconds());
    }

}
